package com.ctrip.study.algorithm.leetcode;

public class ReverseInt {

	public int reverse(int x) {
		StringBuffer sb = new StringBuffer();
		if(x < 0){
			sb = sb.append(x).reverse();
			String s = sb.substring(0, sb.length() - 1);
			s = "-" + s;
			return Integer.valueOf(s);
		}
		String reverseString = sb.append(x).reverse().toString();
        return Integer.valueOf(reverseString);
    }
	
	public static void main(String[] args) {
		System.out.println(new ReverseInt().reverse(-123));
	}
	
}
